import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class EpisodeGetter {

	private static final Pattern EPISODE_PATTERN = Pattern
		.compile("^.*(\\d\\d?)[eExX .](\\d\\d).*$");
	
	public static String getEpisode(String name) {
//		System.out.println("ANALYSE FOR " + name);
		Matcher matcher = EPISODE_PATTERN.matcher(name);
		String result = null;
		if (matcher.matches()) {
			String season = matcher.group(1);
			if (season.length() == 1) {
				season = "0" + season;
			}
			result = "S" + season + "E" + matcher.group(2);
//			System.out.println(result);
		} else {
//			System.out.println("NO MATCH for " + name + ".");
		}
		return result;
	}
}
